package com.fsy.Controller;

import com.fsy.entities.Users;
import com.fsy.service.UsersService;
import com.fsy.utils.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/zdfp")
@CrossOrigin
public class ZDFPController {

    //使用静态变量来保存分量开关的值
    public static  String autoAllocateSwitch = "off";//自动分配的开关，默认值：关

    @GetMapping("find")
    public Map<String,Object> find(){
        //读取数据
        Map<String,Object>  map = new HashMap<>();
        map.put("isLock",autoAllocateSwitch.equals("on") ? "1":"0");

        //返回数据
        List<Map<String,Object>> list = new ArrayList<>();
        list.add(map);
        return Result.toClient("0","success",1,list);
    }

    @PostMapping("set")
    public boolean set(String valid){
        autoAllocateSwitch = valid;
        return autoAllocateSwitch.equals(valid);
    }





























}
